package com.elitedatai.mchtest.manage.repository;

import com.elitedatai.mchtest.manage.model.entity.LogsFileIndexEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface LogsFileIndexRepository extends JpaRepository<LogsFileIndexEntity, Long>, JpaSpecificationExecutor<LogsFileIndexEntity> {
    List<LogsFileIndexEntity> findByFileId(String fileId);

    /**
     * 根据 fileId 列表删除记录
     */
    @Modifying
    @Transactional
    @Query("DELETE FROM LogsFileIndexEntity l WHERE l.fileId IN :fileIds")
    void deleteByFileIds(List<String> fileIds);
}
